﻿Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Windows.Forms
Public Class frmPrintBarcode
    Public MyBarCode As String = ""
    Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    Private Sub frmPrintBarcode_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'CryRepControl1.ReportFileName = "D:\My Documents\Visual Studio 2008\Projects\WHIS\WHIS\RptBarcode.rpt"
        'CryRepControl1.ParameterFields(0) = "StrBarcode;" & "*" & MyBarCode & "*"
        Dim MyRpt As New RptBarcode
        'Dim Para As Integer
        Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
        crReportDocument.Load("D:\My Documents\Visual Studio 2008\Projects\WHIS\WHIS\RptBarcode.rpt")
        Dim ParamFields As New CrystalDecisions.Shared.ParameterFields
        Dim ParamField As New CrystalDecisions.Shared.ParameterField()
        Dim DiscreteVal As New CrystalDecisions.Shared.ParameterDiscreteValue()

        With crReportDocument.DataDefinition
            ParamField.ParameterFieldName = .ParameterFields("StrBarcode").Name
            DiscreteVal.Value = "*" & MyBarCode & "*"
            ParamField.CurrentValues.Add(DiscreteVal)
            ' Add the parameter to the parameter fields collection.
            ParamFields.Add(ParamField)

            crReportDocument.PrintOptions.PrinterName = "Zebra  TLP2844"
            crReportDocument.PrintOptions.PaperSize = PaperSize.DefaultPaperSize

            DiscreteVal = New CrystalDecisions.Shared.ParameterDiscreteValue()
            ParamField = New CrystalDecisions.Shared.ParameterField()


        End With
        With CrystalReportViewer1
            .DisplayGroupTree = False
            .ParameterFieldInfo = ParamFields
            .ReportSource = crReportDocument

        End With



    End Sub
    Private Sub CrystalReportViewer1_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    'Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    '    Dim report As New CrystalDecisions.CrystalReports.Engine.ReportDocument

    '    Dim repName As String

    '    CryRepControl1.ReportFileName = "D:\My Documents\Visual Studio 2008\Projects\WHIS\WHIS\RptBarcode.rpt"
    '    CryRepControl1.ParameterFields(0) = "StrBarcode;" & "*" & MyBarCode & "*"

    '    report.Load(CryRepControl1.ReportFileName)

    '    report.PrintToPrinter(1, False, 1, 1)

    'End Sub

    Private Sub CrystalReportViewer1_Load_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load

    End Sub
End Class